import { Axios } from './core/index'
import { bind, extend, merge } from './utils'
import { defaults } from './defaults'
import { CancelToken } from './cancel'
import type { AxiosInstance, AxiosOption } from '../types'


function createInstance(option:AxiosOption) {
  const thisArg = new Axios(option)
  const instance = bind(Axios.prototype.request, thisArg)

  extend(instance, Axios.prototype, thisArg)
  extend(instance, thisArg)
  
  return instance as unknown as AxiosInstance
}


const axios = createInstance({
  url:'',
  method:''
})

axios.create = function(option:AxiosOption) {
  return createInstance(merge(defaults, option))
}

const instance = axios.create({url:'', method:''})

